package common.hibernate.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.dao.DataAccessException;

import common.hibernate.vo.Page;


public interface BaseService {

	public abstract <T> T load(Class<T> entityClass, Serializable id) throws DataAccessException;

	public abstract <T> T get(Class<T> entityClass, Serializable id) throws DataAccessException;

	public abstract <T> Serializable save(T entity) throws DataAccessException;
	
	public abstract void dbOperation(Object[] saves, Object[] updates, Object[] deletes) throws DataAccessException;
	
	public abstract <T> void save(@SuppressWarnings("unchecked") T ... entities) throws DataAccessException;

	public abstract <T> void saveOrUpdate(T entity) throws DataAccessException;

	public abstract <T> void update(T entity) throws DataAccessException;
	public abstract <T> void update(@SuppressWarnings("unchecked") T ... entities) throws DataAccessException;

	public abstract <T> void delete(T entity) throws DataAccessException;
	public abstract <T> void delete(@SuppressWarnings("unchecked") T ... entities) throws DataAccessException;
	
	public abstract <T> void refresh(T entity) throws DataAccessException;

	public abstract <T> T merge(T entity) throws DataAccessException;

	public abstract void clear() throws DataAccessException;

	public abstract void flush() throws DataAccessException;

	public abstract <T> List<T> loadAll(Class<T> entityClass) throws DataAccessException;

	public abstract <T> List<T> find(String queryString, Object ... values) throws DataAccessException;
	public abstract <T> void executeUpdate(String hql, Object ... values) throws DataAccessException;
	public abstract <T> void executeUpdateForListParamter(String hql, String param, Collection<?> collection, Object ... values) throws DataAccessException;
	
	public abstract <T> T findOne(String queryString, Object ... values) throws DataAccessException;
	
	public abstract int queryTotal(String queryString, Object ... values) throws DataAccessException;

	public abstract <T> Page<T> find(String hql, String countHql, int currentPage, int pageSize, Object... values)
			throws DataAccessException;

	public abstract <T> List<T> findByExample(Object exampleEntity) throws DataAccessException;

	public abstract <T> List<T> findByExample(String entityName, Object exampleEntity, int firstResult, int maxResults)
			throws DataAccessException;

	public abstract <T> Page<T> findByExample(String entityName, int currentPage, int pageSize, Object exampleEntity)
			throws DataAccessException;

	public abstract <T> List<T> findByCriteria(DetachedCriteria criteria) throws DataAccessException;

	public abstract <T> List<T> findByCriteria(DetachedCriteria criteria, int firstResult, int maxResults)
			throws DataAccessException;

	public abstract <T> Page<T> findByCriteriaForPage(DetachedCriteria criteria, int currentPage, int pageSize)
			throws DataAccessException;

	public abstract <T> Page<T> queryForSql(String sql, String countSql, int currentPage, int pageSize, Object ... values)
			throws DataAccessException;
	
	public abstract List<Map<String, Object>> queryForSql(String sql, Object[] objects) throws DataAccessException;

	public abstract <T> List<T> findByParamList(String queryString, List<Object> list, Object[] values) throws DataAccessException;

	public void dbOperation(String hql, Object[] values, Object[] saves, Object[] updates, Object[] deletes)
			throws DataAccessException;

	public int dbOperationForSql(String sql, Object[] values);

	public Session getSession();

}